<?php
/**
 * Created by JetBrains PhpStorm.
 * User: AndreyG
 * Date: 24.01.12
 * Time: 15:01
 * To change this template use File | Settings | File Templates.
 */
function setUrl(array $params)
{
    $url =  $_SERVER['QUERY_STRING'];

    foreach($params as $param => $value) {
        if(strpos($url, $param)) {
            $url = preg_replace("/({$param})\=(\w+)/i", "$1=" . $value, $url);
        } else {
            if(strlen($url) > 0) {
                $url .= '&';
            }
            $url .= $param . '=' . $value;
        }
    }

    return $url;
}

/*
 * MySQLi function get row set
 * @param object mysqli_result
 * return array
 */
function getRowSet(&$result)
{
    if (isset ($result)){
        $z = 0;
        while($row = $result->fetch_assoc()) {
            $rowSet[$z++] = $row;
        }
        return $rowSet;
    }
}

?>
